package com.fuxi.cloud.desreport.b;

import com.fuxi.cloud.common.util.JimuSpringContextUtils;
import com.fuxi.cloud.common.util.oConvertUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;

/**
 * a
 *
 * @Author: 扫地僧
 * @CreateTime: 2021-05-03
 */
public class d {
    private static final Logger r = LoggerFactory.getLogger(d.class);
    public static String a = "";
    public static final String b = "SELECT ";
    public static final String c = " FROM ";
    public static final String d = " AND ";
    public static final String e = " like ";
    public static final String f = " COUNT(*) ";
    public static final String g = " where 1=1  ";
    public static final String h = " where  ";
    public static final String i = " ORDER BY ";
    public static final String j = "asc";
    public static final String k = "desc";
    public static final String l = "=";
    public static final String m = "!=";
    public static final String n = ">=";
    public static final String o = ">";
    public static final String p = "<=";
    public static final String q = "<";

    public d() {
    }

    public static String a(String var0) {
        return " to_date('" + var0 + "','yyyy-MM-dd HH24:mi:ss')";
    }

    public static String getDatabaseType() throws SQLException {
        if (oConvertUtils.isNotEmpty(a)) {
            return a;
        } else {
            DataSource var0 = (DataSource) JimuSpringContextUtils.getApplicationContext().getBean(DataSource.class);
            return a(var0);
        }
    }

    public static String a(DataSource var0) throws SQLException {
        if ("".equals(a)) {
            Connection var1 = var0.getConnection();

            Object var4;
            try {
                DatabaseMetaData var2 = var1.getMetaData();
                String var3 = var2.getDatabaseProductName().toLowerCase();
                if (var3.indexOf("mysql") >= 0) {
                    a = "MYSQL";
                    return a;
                }

                if (var3.indexOf("oracle") >= 0) {
                    a = "ORACLE";
                    return a;
                }

                if (var3.indexOf("sqlserver") >= 0 || var3.indexOf("sql server") >= 0) {
                    a = "SQLSERVER";
                    return a;
                }

                if (var3.indexOf("postgresql") >= 0) {
                    a = "POSTGRESQL";
                    return a;
                }

                var4 = null;
            } catch (Exception var8) {
                r.error(var8.getMessage(), var8);
                return a;
            } finally {
                var1.close();
            }

            return (String)var4;
        } else {
            return a;
        }
    }
}